#ifndef LOGINDLG_H
#define LOGINDLG_H
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
            TypeName(const TypeName&); \
            void operator=(const TypeName&)

#include <QDialog>
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>

#include "stepquerythread.h"
#include "fileselectdlg.h"
#include "mainwindow.h"
#include "logger.h"
#include "projectinfo.h"
#include "targetuser.h"
#include "procedure.h"

namespace Ui {
class loginDlg;
}

class loginDlg : public QDialog
{
    Q_OBJECT

public:
    explicit loginDlg(QWidget *parent = nullptr);
    virtual ~loginDlg();

    bool f_MakeConnToDb();
    void judgeLogin(const QSet<TargetUser> &user, int count);
    //bool loginVerify(QString usrId, QString pwd);

signals:
    void signal_DbConnected();
    void signal_ProjectListConstructed();
    void signal_ParameterLocked();
    void signal_ParameterUnlocked();

private slots:
    void on_exit_btn_clicked();

    void on_login_btn_clicked();

    void slot_DbConnected();

    void slot_ProjectListConstructed() const;

    void on_projSelectComboBox_currentIndexChanged(int index);

    void on_lock_btn_toggled(bool checked);

    void slot_ParameterLocked();

    void slot_ParameterUnlocked();

    void processQuerySignal(QStringList);

private:
    DISALLOW_COPY_AND_ASSIGN(loginDlg);
    Ui::loginDlg *ui;
    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");

    //QString md5(QString str);
    QString loginId;

    QString host;
    unsigned short port = 0;

    Logger logger;

    StepQueryThread *queryThread;
    
    QList<ProjectInfo> projInfoList;

    int targetLoginNumber = 0;
    int lastSetCnt = 0;
};
#endif // LOGINDLG_H
